import { request } from '../request';

/**
 * Send chat message to backend API
 *
 * @param models List of models to use (e.g., ['openai', 'ernie', 'deepseek'])
 * @param message Message content
 * @param accessToken Optional access token for models like 'ernie' (Wenxin)
 */
export function fetchChat(models: string[], message: string, accessToken?: string) {
  return request<Api.Chat.AIResponse[]>({
    data: {
      models,    // 传递多个模型名
      message,   // 用户消息内容
      access_token: accessToken,  // Wenxin 模型需要 access_token
    },
    method: 'post',
    url: '/chat/',  // 后端接口
    timeout: 500000,  // 设置请求超时时间
  });
}
